package com.atguigu1.core.action

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * @description: 行动算子案例
 * @time: 2021-03-12 11:45
 * @author: baojinlong
 **/
object Spark01CollectAction {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    // 设置rdd分区数字
    val sparkContext = new SparkContext(conf)
    val rdd: RDD[Int] = sparkContext.makeRDD(Seq(1, 2, 3, 4))
    // 所谓行动算子其实就是触发作业Job执行的方法,底层代码会创建ActiveJob,并提交执行
    // dagScheduler.runJob(rdd, cleanedFunc, partitions, callSite, resultHandler, localProperties.get)
    rdd.collect.foreach(println)
    sparkContext.stop()
  }
}
